<?php

namespace App\Repos;

use App\Models\ClientCar as Car;
use App\Models\Task;

class CarRepo 
{
    public static function find($where=[])
    {
    	return Car::where($where)->first();
    }

    public static function destroy($id)
    {
    	$rs['status'] = false;
    	$task = Task::where(['car_id'=>$id])->first();
    	if($task&&object_get($task,'status')!=100) {
    		$rs['msg'] = '此车辆关联工单'.$task->code.'尚未完成，因此不能被删除';
    		return $rs;
    	}
    	Car::destroy($id);
    	$rs['status'] = true;
    	return $rs;
    }
}
